package com.cy.web.action.system;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;

import com.cy.bean.system.IndexNavi;
import com.cy.service.system.IndexNaviService;

/**
 * 系统初始化控制器
 * 在系统安装完成之后调用
 * @author CY
 *
 */
@Controller
public class SystemInitAction {

	@Resource
	private IndexNaviService indexNaviService;
	
	public void execute() {
		addIndexNavi();
	}

	/**
	 * 添加首页导航数据
	 */
	private void addIndexNavi() {
		// 数据库中没有首页导航数据
		if(indexNaviService.getCount() < 1) {
			indexNaviService.save(new IndexNavi("首页", "", "glyphicon glyphicon-home"));
			indexNaviService.save(new IndexNavi("路线", "busLine", "glyphicon glyphicon-align-left"));
			indexNaviService.save(new IndexNavi("车站", "station", "glyphicon glyphicon-flag"));
			indexNaviService.save(new IndexNavi("新闻", "news_list", "glyphicon glyphicon-globe"));
			indexNaviService.save(new IndexNavi("发现", "scenic_list", "glyphicon glyphicon-eye-open"));
			indexNaviService.save(new IndexNavi("反馈", "feedback", "glyphicon glyphicon-envelope"));
			indexNaviService.save(new IndexNavi("关于我们", "about", "glyphicon glyphicon-user" , true));
			indexNaviService.save(new IndexNavi("联系我们", "contact", "glyphicon glyphicon-phone" , true));
			indexNaviService.save(new IndexNavi("divider", null, null,true));
			indexNaviService.save(new IndexNavi("新浪微博", "http://weibo.com/u/2680532347",  "glyphicon glyphicon-heart", true));
		}
	}
	
}
